Ext
		.define(
				'com.hh.workflow.task.TaskList',
				{
					extend : 'com.hh.global.SimpleGroupGridPanel',
					title : '我的工作',
					action : 'workflow-Task-queryTaskList',
					deleteAction : 'workflow-Task-deleteProcessDefinitions',
					constructor : function(config) {
						this.config = config || {};
						this.superclass.constructor.call(this, this.config);
						this.init();
					},
					groupHeaderTpl : '{name}&nbsp;&nbsp;&nbsp;&nbsp;共：{rows.length} 条',
					getStoreFields : function() {
						return [ 'id', 'name', 'group', 'pdid', 'pdkey',
								'activityId', 'pdName', 'createTime', 'piid',
								'startUserName' ];
					},
					groupField : 'group',
					getGridColumns : function() {
						return [
								{
									text : 'id',
									flex : 1,
									dataIndex : 'id',
									hidden : true
								},
								{
									text : '流水号',
									dataIndex : 'piid',
									flex : 1
								},
								{
									text : '流程名称',
									flex : 1,
									dataIndex : 'pdName'
								},
								{
									text : '发起人',
									flex : 1,
									dataIndex : 'startUserName'
								},
								{
									text : '节点名称',
									flex : 1,
									dataIndex : 'name'
								},
								{
									text : '任务创建时间',
									dataIndex : 'createTime',
									width : 200,
									renderer : Ext.util.Format
											.dateRenderer('Y年m月d日 H时i分s秒')
								} ];
					},
					getContainerRightMenuItems : function() {
						return [ this.getToolbarItem("search") ];
					},
					getMyToolbarItem : function(type) {
						var page = this;
						if (type == 'manager') {
							return {
								icon : 'struts-image?path=com/hh/workflow/img/shape_square_edit.png',
								text : '办理',
								handler : function() {
									page.doManager();
								}
							};
						} else if (type == 'select') {
							return {
								iconCls : 'search',
								text : '查看历史',
								handler : function() {
									page.doSelectHi();
								}
							};
						} else if (type == 'claim') {
							return {
								icon : 'struts-image?path=com/hh/workflow/img/shape_square_edit.png',
								text : '领取',
								handler : function() {
									page.doClaim();
								}
							};
						}
					},
					doClaim : function() {
						var record = this.getGridRecord();
						if (record == null) {
							ExtFrame.info("请选中您要查看历史的流程！！");
							return;
						}
						Request.request('workflow-Task-claim', {
							taskId : record.get("id")
						});
					},
					doSelectHi : function() {
						var record = this.getGridRecord();
						if (record == null) {
							ExtFrame.info("请选中您要查看历史的流程！！");
							return;
						}
						var win = ExtUtil.create(
								'com.hh.workflow.task.HiTaskList', {
									id : this.id
											+ '-'
											+ 'com.hh.workflow.task.HiTaskList'
													.replace(/\./g, ''),
									parentPanel : this,
									extraParams : {
										piid : record.get("piid"),
										pdid : record.get("pdid")
									}
								});
						win.show();
					},
					getRightMenuItems : function() {
						var panel = this;
						return [ this.getMyToolbarItem("manager"),
						// this.getMyToolbarItem("claim"),
						this.getMyToolbarItem("select"),
								this.getToolbarItem("search") ];
					},
					getTbarItems : function() {
						var panel = this;
						return [ this.getMyToolbarItem("manager"),
						// this.getMyToolbarItem("claim"),
						this.getMyToolbarItem("select"),
								this.getToolbarItem("search") ];
					},
					statics : {
						doManager : function(grid, paramMap) {
							var record = grid.getSelectionModel()
									.getLastSelected();
							if (Util.isNull(record)) {
								ExtFrame.info("请选中要办理的数据！");
							} else {
								Request
										.request(
												'workflow-Task-manager',
												{
													activityId : record
															.get("activityId"),
													pdkey : record.get("pdkey"),
													taskId : record.get("id"),
													actionType : paramMap.actionType
												},
												function(result) {
													if (result.href) {
														var callbackRefresh = function() {
															grid.getStore()
																	.load();
														}
														var params = {};
														Ext
																.apply(
																		params,
																		Ext
																				.decode(result.hrefParams));
														params.objectId = result.objectId;
														params.taskId = result.taskId;
														params.piid = result.piid;
														params.pdid = record
																.get("pdid");
														params.activityId = record
																.get("activityId");
														params.title = record
																.get("pdName")
																+ "（"
																+ record
																		.get("name")
																+ "）";
														params.pdName = record
																.get("pdName");
														params.actName = record
																.get("name");
														params.addWindow = false;
														params.callbackRefresh = callbackRefresh;
														params.actConfig = result;
														params.actionType = paramMap.actionType;
														Desktop.openWindow(
																result.href,
																params);
													} else {
														ExtFrame.info("没指定表单！");
													}
												});
							}
						}
					},
					doManager : function() {
						com.hh.workflow.task.TaskList.doManager(this.grid, {
							actionType : 'manager'
						});
					}
				});